import {defineStore} from "pinia";
import {computed, ref} from "vue";

/*Setup store  方式，ref 应用的就是响应式的
* */
export const useCounterStore = defineStore('counter', () => {
    const count = ref(0)

    function $reset() {
        count.value = 0
    }

    const bigSum = computed({
        get() {
            return count.value * 10
        },
        set(val) {
            count.value = val
        }
    }, {
        onTrack(event) {
            console.log('onTrack', event)
        },
        onTrigger(event) {
            console.log('onTrigger', event)
        }
    })

    function increment() {
        count.value++
    }

    return {count, $reset, increment, bigSum}
})
